package com.yugao.fintech.antelope.shop.controller.admin;

import com.yugao.fintech.antelope.base.ram.ActionType;
import com.yugao.fintech.antelope.base.ram.RamResource;
import com.yugao.fintech.antelope.shop.service.TableCategoryService;
import com.yugao.fintech.antelope.shop.service.TableService;
import com.yugao.fintech.framework.core.response.Resp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;

import java.util.List;

/**
 * 店铺桌台
 * 

 */
@Api(tags = "店铺桌台")
@RestController
@RequestMapping("/table")
public class ShopTableController {
    @Autowired
    private TableService tableService;

    @Autowired
    private TableCategoryService tableCategoryService;

    @ApiOperation(value = "查询店铺桌台")
    @GetMapping("/listTable")
    @RamResource(action = "shopTable:table:query", name = "查询店铺桌台", type = ActionType.READ)
    public Resp<List<TableResp>> listTable(@Validated TableListReq req) {
        return Resp.ok(tableService.listTable(req));
    }

    @ApiOperation(value = "通过id查找店铺桌台")
    @GetMapping("/getTable")
    @RamResource(action = "shopTable:table:query", name = "查询店铺桌台", type = ActionType.READ)
    public Resp<TableResp> getTable(@RequestParam(value = "id") Long id) {
        return Resp.ok(tableService.getTable(id));
    }
  
    @ApiOperation(value = "保存店铺桌台")
    @PostMapping("/saveTable")
    @RamResource(action = "shopTable:table:save", name = "保存店铺桌台", type = ActionType.WRITE)
    public Resp<?> saveTable(@Validated @RequestBody TableSaveReq req) {
        return Resp.ok(tableService.saveTable(req));
    }
  
    @ApiOperation(value = "更新店铺桌台")
    @PostMapping("/updateTable")
    @RamResource(action = "shopTable:table:update", name = "更新店铺桌台", type = ActionType.WRITE)
    public Resp<?> updateTable(@Validated @RequestBody TableUpdateReq req) {
        return Resp.ok(tableService.updateTable(req));
    }
  
    @ApiOperation(value = "批量删除店铺桌台")
    @DeleteMapping("/batchDeleteTable")
    @RamResource(action = "shopTable:table:delete", name = "删除店铺桌台", type = ActionType.WRITE)
    public Resp<?> batchDeleteTable(@RequestParam(value = "ids") List<Long> ids) {
        return Resp.ok(tableService.batchDeleteTable(ids));
    }
  
    @ApiOperation(value = "删除店铺桌台")
    @DeleteMapping("/deleteTable")
    @RamResource(action = "shopTable:table:delete", name = "删除店铺桌台", type = ActionType.WRITE)
    public Resp<?> deleteTable(@RequestParam(value = "id") Long id) {
        return Resp.ok(tableService.deleteTable(id));
    }

    @ApiOperation(value = "查询桌台分类")
    @GetMapping("/listCategory")
    @RamResource(action = "shopTable:category:query", name = "查询桌台分类", type = ActionType.READ)
    public Resp<List<TableCategoryResp>> listCategory() {
        return Resp.ok(tableCategoryService.listCategory());
    }

    @ApiOperation(value = "保存桌台分类")
    @PostMapping("/saveCategory")
    @RamResource(action = "shopTable:category:save", name = "保存桌台分类", type = ActionType.WRITE)
    public Resp<?> saveCategory(@Validated @RequestBody TableCategorySaveReq req) {
        return Resp.ok(tableCategoryService.saveCategory(req));
    }

    @ApiOperation(value = "更新桌台分类")
    @PostMapping("/updateCategory")
    @RamResource(action = "shopTable:category:update", name = "更新桌台分类", type = ActionType.WRITE)
    public Resp<?> updateCategory(@Validated @RequestBody TableCategoryUpdateReq req) {
        return Resp.ok(tableCategoryService.updateCategory(req));
    }

    @ApiOperation(value = "批量删除桌台分类")
    @DeleteMapping("/batchDeleteCategory")
    @RamResource(action = "shopTable:category:delete", name = "删除桌台分类", type = ActionType.WRITE)
    public Resp<?> batchDeleteCategory(@RequestParam(value = "ids") List<Long> ids) {
        return Resp.ok(tableCategoryService.batchDeleteCategory(ids));
    }

    @ApiOperation(value = "删除桌台分类")
    @DeleteMapping("/deleteCategory")
    @RamResource(action = "shopTable:category:delete", name = "删除桌台分类", type = ActionType.WRITE)
    public Resp<?> deleteCategory(@RequestParam(value = "id") Long id) {
        return Resp.ok(tableCategoryService.deleteCategory(id));
    }
}
